package com.example.observer;

import com.example.observer.fan.Impi.FanImpi;

/**
 * 观察者模式，需要将观察者注册到被观察者内部
 */
public class Test {
    public static void main(String[] args) {
        String bloggerName = "博主";
        FanImpi fanImpi1 = new FanImpi(bloggerName);
        FanImpi fanImpi2 = new FanImpi(bloggerName);
        FanImpi fanImpi3 = new FanImpi(bloggerName);

        Blogger blogger = new Blogger(bloggerName);
        blogger.addFan(fanImpi1);
        blogger.addFan(fanImpi2);
        blogger.addFan(fanImpi3);

        blogger.notifyFan("发布一个新视频");

        blogger.removeFan(fanImpi1);

        blogger.notifyFan("发布了一篇文章");
    }
}
